<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />

<link href="${ctx}/style/default.css" rel="stylesheet" type="text/css" media="screen" />
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>

<script>
    var my_window;
    function AddItemtoList(objSelect,item,texto,codSelected)
	{
            var combo = document.getElementById(objSelect);
		var opt = document.createElement("option");
		opt.text = texto;
		opt.value = item;
		if(codSelected != null && opt.value == codSelected){
			opt.selected = true;
		}
		if(combo != null){
			combo.options.add(opt);
		}
	}
        function onlyNumbers(e) {
            //onkeypress="return onlyNumbers(event);"
		if ([e.keyCode || e.which] == 8 || [e.keyCode || e.which] == 46 || [e.keyCode || e.which] == 47)
			return true;
		if ([e.keyCode || e.which] < 48 || [e.keyCode || e.which] > 57)
			e.preventDefault ? e.preventDefault() : e.returnValue = false;

	}

            function validarEnteros(e) {
            //onkeypress="return onlyNumbers(event);"
		if ([e.keyCode || e.which] == 8)
			return true;
		if ([e.keyCode || e.which] < 48 || [e.keyCode || e.which] > 57)
			e.preventDefault ? e.preventDefault() : e.returnValue = false;

	}

function validarFormatoFecha(Cadena){
    if (Cadena == "")
    {
        return true;
    }
    
    var Fecha= new String(Cadena)//   ⁄⁄ Crea un string
    var RealFecha= new Date() //  ⁄⁄ Para sacar la fecha de hoy
     //(Cadena Año
    var Ano= new String(Fecha.substring(Fecha.lastIndexOf("/")+1,Fecha.length))
     //Cadena Mes
    var Mes= new String(Fecha.substring(Fecha.indexOf("/")+1,Fecha.lastIndexOf("/")))
    //Cadena Día
    var Dia= new String(Fecha.substring(0,Fecha.indexOf("/")))
        
    //Valido el año
    if (isNaN(Ano) || Ano.length<4 || parseFloat(Ano)<1900){
            alert('Año inválido')
        return false
    }
    // Valido el Mes
    if (isNaN(Mes) || parseFloat(Mes)<1 || parseFloat(Mes)>12){
        alert('Mes inválido')
        return false
    }
    //Valido el Dia
    if (isNaN(Dia) || parseInt(Dia, 10)<1 || parseInt(Dia, 10)>31){
        alert('Día inválido')
        return false;
    }
    if (Mes==4 || Mes==6 || Mes==9 || Mes==11 || Mes==2) {
        if (Mes==2 && Dia > 28 || Dia>30) {
            alert('Día inválido')
            return false;
        }
    }
}
      function compare_dates(fecha, fecha2)
      {
        var xMonth=fecha.substring(3, 5);
        var xDay=fecha.substring(0, 2);
        var xYear=fecha.substring(6,10);
        var yMonth=fecha2.substring(3, 5);
        var yDay=fecha2.substring(0, 2);
        var yYear=fecha2.substring(6,10);
        if (xYear> yYear)
        {
            return(true)
        }
        else
        {
          if (xYear == yYear)
          {
            if (xMonth> yMonth)
            {
                return(true)
            }
            else
            {
              if (xMonth == yMonth)
              {
                if (xDay> yDay)
                  return(true);
                else
                  return(false);
              }
              else
                return(false);
            }
          }
          else
            return(false);
        }
    }

function popuponclick()
    {
     my_window = window.open("",
        "mywindow","status=1,width=350,height=150");
     my_window.document.write('<H1>The Popup Window</H1>');
    }

function Abrir_ventana (pagina) {
var opciones="toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, width=700, height=450, top=85, left=140";
window.open(pagina,"",opciones);
}

function ValidarMaximoCaracteres(txt, dst, formul, maximo)
    {
    var largo
        largo = formul[txt].value.length
    if (largo > maximo)
        formul[txt].value = formul[txt].value.substring(0,maximo)
        formul[dst].value = formul[txt].value.length
    }
    
   




function closepopup()
    {
     //if(false == my_window.closed)
     //{
        //my_window.close ();
        window.close();
     //}
     //else
     //{
       // alert('Window already closed!');
     //}
}
</script>

